package com.edu.controller;

import com.edu.entity.StuScore;
import com.edu.service.SchoolService;
import com.edu.service.UsersService;
import com.edu.vo.Result;
import com.edu.vo.StuScoreVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName StudentController
 * @Description  后台学生管理
 * @Author W.Jian
 * @Date 2021/5/23 20:25
 **/
@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired
    private UsersService usersService;
    @Autowired
    private SchoolService schoolService;

    /**
     * 根据当前用户id查询对应角色权限的学生
     * @param userId
     * @return
     */
    @GetMapping("get")
    public Result getStudent(Long userId){
        return usersService.get(userId);
    }

    /**
     * 添加分数  修改分数
     * @param stuScore
     * @return
     */
    @PostMapping("addOrUpdateScore")
    public Result addScore(@RequestBody StuScore stuScore){
        return usersService.addScore(stuScore);
    }

    /**
     * 删除分数
     * @param id
     * @return
     */
    @DeleteMapping("delete/{id}")
    public Result deleteStudent(@PathVariable("id") Long id){
        return usersService.deleteStuScore(id);
    }

    /**
     * 查询分数
     * @param stuScore
     * @return
     */
    @PostMapping("selectScore")
    public Result selectScore(@RequestBody StuScoreVo stuScore){
        return usersService.selectScore(stuScore);
    }
}
